﻿using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Validation.Configuration;
using System;

namespace AsNum.Common.EntLib.Validation.Adapters {
    public class AndCompositeClientAdapter : BaseClientAdapter<AndCompositeValidatorData> {

        public AndCompositeClientAdapter(AndCompositeValidatorData data , Dictionary<string , Tuple<string , string>> map , bool isSub = false)
            : base ( data , map ) {

            List<BaseClientAdapter> adapters = new List<BaseClientAdapter> ( );
            data.Validators.ForEach ( (v) => {
                adapters.Add ( ClientAdapterFactory.GetAdapter ( v , map , true ) );
            } );

            this.SubAdapters = adapters;

            //if ( adapters.Count > 0 ) {
            //    var dict = new Dictionary<string , List<BaseClientAdapter>> ( );
            //    dict.Add ( this.Key , adapters );
            //    var rules = ValidationHelper.GetRules ( dict  , this.Map );
            //    this.AddRule ( RuleKeys.SubRule , ValidationHelper.FormatExport ( rules, this.Detph ) );
            //}

        }

        public override RuleTypes RuleType {
            get {
                return RuleTypes.And;
            }
        }
    }
}
